package com.flying.planewar;

import com.flying.planewar.utils.PlaneUtil;

import java.awt.*;
import java.io.PipedOutputStream;

/**
 * @author 刘鹏飞
 * @Classname Explode
 * @Date 2024/12/17 23:00
 * @Created by 刘鹏飞
 * @Description 爆炸类
 */
public class Explode {
    double x,y;
    static Image[] images=new Image[16];

    static {
        // 加载所有的图片
        for (int i = 0; i < images.length; i++) {
            images[i]=PlaneUtil.getImage("images/explode/e"+(i+1)+".gif");
            // 懒加载
            images[i].getWidth(null);
        }


    }
    int count;
    boolean live = true;
    public void draw(Graphics g){
        if(!live){
            return;
        }
        if(count<=15){
            g.drawImage(images[count], (int)x, (int)y, null);
            count++;
        }else{
            live = false;
        }
    }

    public Explode(double x, double y) {
        this.x = x;
        this.y = y;
    }
}
